
CC=g++

TOPDIR=..
GTEST_DIR=gtest-1.6.0

INCLUDES=-I$(GTEST_DIR)/include -I$(TOPDIR)/include
LIBS=
DEFINES=-D__STDC_LIMIT_MACROS
OPTIMIZATION=
CXXFLAGS=$(INCLUDES) $(DEFINES) -c -Wall $(OPTIMIZATION)
LDFLAGS=$(LIBS) -lm -lpthread

SOURCES=buffer_test.cpp
OBJECTS=$(SOURCES:.cpp=.o)

GTEST_FILES=gtest.a gtest_main.a gtest-all.o gtest_main.o

HEADERS=$(TOPDIR)/include/*.h
EXECUTABLES=buffer_test

all: $(SOURCES) $(EXECUTABLES)

clean:
	rm -f $(OBJECTS) $(EXECUTABLES) $(GTEST_FILES)

# Builds gtest.a and gtest_main.a.

# All Google Test headers.  Usually you shouldn't change this
# definition.
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
                $(GTEST_DIR)/include/gtest/internal/*.h

# Usually you shouldn't tweak such internal variables, indicated by a
# trailing _.
GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)

# For simplicity and to avoid depending on Google Test's
# implementation details, the dependencies specified below are
# conservative and not optimized.  This is fine as Google Test
# compiles fast and for ordinary users its source rarely changes.
gtest-all.o : $(GTEST_SRCS_)
	$(CXX) -I$(GTEST_DIR) $(CXXFLAGS) $(GTEST_DIR)/src/gtest-all.cc

gtest_main.o : $(GTEST_SRCS_)
	$(CXX) -I$(GTEST_DIR) $(CXXFLAGS) $(GTEST_DIR)/src/gtest_main.cc

gtest.a : gtest-all.o
	$(AR) $(ARFLAGS) $@ $^

gtest_main.a : gtest-all.o gtest_main.o
	$(AR) $(ARFLAGS) $@ $^

$(EXECUTABLES): $(OBJECTS) gtest.a gtest_main.a
	$(CC) $(LDFLAGS) $^ -o $@

.cpp.o: $(HEADERS)
	$(CC) $(CXXFLAGS) $< -o $@

